package com.dahuyou.netty.springboot.test;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;

/**
 * 同意增加换行符的outbound handler
 */
public class MyAddNewLineOutMsgHandler extends ChannelOutboundHandlerAdapter {

    @Override // 调用ctx的writeAndFlush方法时会被该方法拦截执行
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        System.out.println("MyAddNewLineOutMsgHandler--统一增加换行符咯！！！");
        msg += "\r\n";
        super.write(ctx, msg, promise);
    }

}
